package com.rui.shiliao;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.Gallery;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cxj.andone.IOUtil;
import com.cxj.shiliao.R;

public class ViewActivity extends SLAppActivity {
    private void setPhoto(Gallery paramGallery, List<String> paramList) {
        ArrayList localArrayList = new ArrayList();
        Iterator localIterator = paramList.iterator();
        while (true) {
            if (!localIterator.hasNext()) {
                paramGallery.setAdapter(new PhotoAdapter(this, 0, localArrayList));
                ViewGroup.MarginLayoutParams localMarginLayoutParams = (ViewGroup.MarginLayoutParams) paramGallery.getLayoutParams();
                localMarginLayoutParams.setMargins(-150, localMarginLayoutParams.topMargin, localMarginLayoutParams.rightMargin,
                        localMarginLayoutParams.bottomMargin);
                return;
            }
            String str = (String) localIterator.next();
            if (str.indexOf(".png") < 0)
                continue;
            try {
                localArrayList.add(BitmapFactory.decodeStream(getResources().getAssets().open("image/" + str)));
            } catch (IOException localIOException) {
                localIOException.printStackTrace();
            }
        }
    }

    private void setText(TextView paramTextView, List<String> paramList) {
        Iterator localIterator = paramList.iterator();
        while (localIterator.hasNext()) {
            String str1 = (String) localIterator.next();
            if (str1.indexOf(".txt") == -1) {
                continue;
            }
            BufferedReader localBufferedReader = null;
            InputStream localInputStream = null;
            try {
                localInputStream = getResources().getAssets().open("txt/" + str1);
                localBufferedReader = new BufferedReader(new InputStreamReader(localInputStream));

                String localObject = localBufferedReader.readLine();
                while (localObject != null) {
                    paramTextView.setText(paramTextView.getText() + "\n" + (String) localObject);
                    localObject = localBufferedReader.readLine();
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                IOUtil.closeQuitely(localInputStream);
                IOUtil.closeQuitely(localBufferedReader);
            }
        }
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.view);
        String str1 = getIntent().getExtras().getString("title");
        Map localMap = (Map) ShiLiaoActivity.worlds.get(str1);
        ((TextView) findViewById(R.id.textView_Name)).setText(str1);
        Object[] arrayOfObject = localMap.keySet().toArray();
        int i = arrayOfObject.length;
        int j = 0;
        while (j < i) {
            String str2 = arrayOfObject[j].toString();
            if (str2.indexOf("禁忌") >= 0) {
                ((TextView) findViewById(R.id.textView_Jin)).setText(str2);
                setText((TextView) findViewById(R.id.textView_C_Jin), (List) localMap.get(str2));
                setPhoto((Gallery) findViewById(R.id.gallery_Jin), (List) localMap.get(str2));
            } else if (str2.indexOf("建议") >= 0) {
                ((TextView) findViewById(R.id.textView_Jian)).setText(str2);
                setText((TextView) findViewById(R.id.textView_C_Jian), (List) localMap.get(str2));
                setPhoto((Gallery) findViewById(R.id.gallery_Jian), (List) localMap.get(str2));
            } else if (str2.indexOf("食谱") >= 0) {
                ((TextView) findViewById(R.id.textView_Shi)).setText(str2);
                setText((TextView) findViewById(R.id.textView_C_Shi), (List) localMap.get(str2));
                setPhoto((Gallery) findViewById(R.id.gallery_Shi), (List) localMap.get(str2));
            }
            j++;
        }
        setAdLayout((LinearLayout) findViewById(R.id.linearLayout_Ad));
    }
}

/* Location:           F:\temp\tools\classes_dex2jar.jar
 * Qualified Name:     com.rui.shiliao.ViewActivity
 * JD-Core Version:    0.6.0
 */